import Vue from 'vue'
import VueRouter from 'vue-router'
Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: '/store'
  }, {
    path: '/ebook',
    component: () => import('@/views/ebook/index.vue'),
    children: [{
      path: ':fileName',
      component: () => import('@/components/ebook/EbookReader.vue')
    }]
  },
  {
    path: '/store',
    component: () => import('@/views/store/index.vue'),
    redirect: '/store/shelf',
    children: [{
      /**
       * 以“/”开头的嵌套路径会被当作根路径，所以子路由上不用加“/”;在生成路由时，
       * 主路由上的path会被自动添加到子路由之前，所以子路由上的path不用在重新声明主路由上的path了
       * */
      path: 'home',
      component: () => import('@/views/store/StoreHome.vue')
    }, {
      path: 'list',
      component: () => import('../views/store/StoreList.vue')
    }, {
      path: 'detail',
      component: () => import('../views/store/StoreDetail.vue')
    }, {
      path: 'shelf',
      component: () => import('../views/store/StoreShelf.vue')
    }, {
      path: 'category',
      component: () => import('../views/store/StoreCategory.vue')
    }, {
      path: 'speaking',
      component: () => import('../views/store/StoreSpeaking.vue')
    }]
  }
]

const router = new VueRouter({
  routes
})

export default router
